home *** CD-ROM | disk | FTP | other *** search
/ PC World 2006 July & August / PCWorld_2006-07-08_cd.bin / v cisle / acehtml / acehtmlfreeware.exe / scriptdef / Mortgage Calculator.sd < prev    next >
INI File  |  2004-06-28  |  5KB  |  159 lines

  1. [SUBJECT]
  2. Description=Calculate mortgages
  3. ImageIndex=-1
  4. Folder=Mathematics
  5.  
  6.  
  7. [HEAD_TEXT]
  8. ;<!-- Cut-N-Paste JavaScript from ISN Toolbox 
  9. ;     Copyright 1996, Infohiway, Inc.  Restricted use is hereby
  10. ;     granted (commercial and personal OK) so long as this code
  11. ;     is not *directly* sold and the copyright notice is buried
  12. ;     somewhere deep in your HTML document.  A link to our site
  13. ;     http://www.infohiway.com is always appreciated of course,
  14. ;     but is absolutely and positively not necessary. ;-)   -->
  15. ;<script language="JavaScript">
  16. ;<!--Hide JavaScript from Java-Impaired Browsers
  17. ;var irate, mi, cmi, years, tprinc, princ, paym, cpaym, osp,v,downp,downr,comp;
  18. ;function calcPaym(cdn){
  19. ;   tprinc = round2d(parseFloat(document.smpc.tprinc.value));
  20. ;   downp = .01*parseFloat(document.smpc.downp.value);
  21. ;   downr = ceil2d(downp*tprinc);
  22. ;   princ = tprinc-downr;
  23. ;   
  24. ;   document.smpc.princ.value = fmt2d(princ,0);
  25. ;   document.smpc.downr.value = fmt2d(downr,0);
  26. ;   
  27. ;   if(cdn)comp="Canadian"; else comp="U.S";
  28. ;   document.smpc.comp.value = comp;
  29. ;   
  30. ;   irate = .01*parseFloat(document.smpc.percent.value);
  31. ;   years=parseFloat(document.smpc.years.value);
  32. ;   term = parseFloat(document.smpc.term.value);
  33. ;   if(term > years)term=years;
  34. ;   
  35. ;   if (term==0 || years==0||irate<.0001||princ<1)
  36. ;   {alert("values must be numeric");}
  37. ;   else 
  38. ;   {
  39. ;       if(cdn)mi = Math.pow(1+ irate/2,1/6);
  40. ;       else   mi = 1+(irate/12);
  41. ;       v = 1/mi;
  42. ;       paym = ceil2d(princ*(mi-1)/(1-Math.pow(mi,-(years*12))));
  43. ;       osp = (princ-(v*paym*(1-Math.pow(v,12*term)))/(1-v))/Math.pow(v,12*term);
  44. ;       if(osp<0)osp = 0;
  45. ;       
  46. ;       document.smpc.paym.value=fmt2d(paym,0);
  47. ;       document.smpc.owed.value = fmt2d(osp,0);
  48. ;   }
  49. ;}
  50. ;function round2d(n){return(.01* Math.round(100*n));}
  51. ;function floor2d(n){return(.01* Math.floor(100*n));}
  52. ;function ceil2d(n){return(.01* Math.ceil(100*n));}
  53. ;// format number n as string width w with 2 decimal places
  54. ;function fmt2d(n,w)
  55. ;{
  56. ;   var work,dp,sl,dl;
  57. ;   
  58. ;   work = ""+floor2d(n); // force only 2 decimals
  59. ;   sl=work.length;
  60. ;   
  61. ;   if(-1 == (dp = work.indexOf(".")))work=work+".00";
  62. ;   else if(3 > sl-dp)work = work+".00"+substring(sl-dp,3);
  63. ;   sl = work.length;
  64. ;   if(0 != w && w !=sl)
  65. ;      if(w<sl){work = "*";for(sl=1;sl<w;sl++)work=work+"*";}
  66. ;      else for(;sl<w;sl++)work=" "+work; 
  67. ;   return work;
  68. ;}
  69. ;//-->
  70. ;</SCRIPT>
  71. ;
  72.  
  73.  
  74. [BODY_TAG]
  75. ;bgcolor="#ffffff" text="#000000" onload="calcPaym(1)" link="#ff0000"   vlink="#0000ff" alink="#000000"
  76.  
  77.  
  78.  
  79. [BODY_TEXT]
  80. ;    <h1>`Caption`</h1>
  81. ;    
  82. ;    <form name="smpc">
  83. ;    <div align="center">
  84. ;    
  85. ;    <p align="left"><b>This calculator calculates U.S. and Canadian monthly
  86. ;      mortgage payments based on principal, interest and term. U.S. mortgages
  87. ;      are compounded monthly while Canadian mortgages are compounded
  88. ;      semi-annually.</B></P> 
  89. ;    <table border="0" cellpadding="5" summary="">
  90. ;      <tr>
  91. ;        <td align="right">
  92. ;        
  93. ;        <p>Amortization(Years) = </p></td>
  94. ;        <td><input type="text" name="years" value="25" size="3"></td>
  95. ;      </tr>
  96. ;      <tr>
  97. ;        <td align="right">
  98. ;        
  99. ;        <p>Term (Years) = </p></td>
  100. ;        <td><input type="text" name="term" value="5" size="3"></td>
  101. ;      </tr>
  102. ;      <tr>
  103. ;        <td align="right">
  104. ;        
  105. ;        <p>Yearly Interest Rate (%) = </p></td>
  106. ;        <td><input type="text" name="percent" value="7" size="6"></td>
  107. ;      </tr>
  108. ;      <tr>
  109. ;        <td align="right">
  110. ;        
  111. ;        <p> Principal Amount ($) = </p></td>
  112. ;        <td><input type="text" value="100000" name="tprinc" size="10"></td>
  113. ;      </tr>
  114. ;      <tr>
  115. ;        <td align="right">
  116. ;        
  117. ;        <p> Downpayment (%) = </p></td>
  118. ;        <td><input type="text" value="25" name="downp" size="10"></td>
  119. ;      </tr>
  120. ;      <tr>
  121. ;        <td align="right"><input type="button" value="calculate payment (canadian)"
  122. ;onclick="calcPaym(1)"></td>
  123. ;        <td><input type="button" value="Calculate Payment (U.S)"
  124. ;onclick="calcPaym(0)"></td>
  125. ;      </tr>
  126. ;      <tr>
  127. ;        <td align="right">
  128. ;        
  129. ;        <p> Downpayment Required ($) =</p></td>
  130. ;        <td><input type="text" name="downr" size="10"></td>
  131. ;      </tr>
  132. ;      <tr>
  133. ;        <td align="right">
  134. ;        
  135. ;        <p> Mortgage Principal ($) =</p></td>
  136. ;        <td><input type="text" name="princ" size="10"></td>
  137. ;      </tr>
  138. ;      <tr>
  139. ;        <td align="right">
  140. ;        
  141. ;        <p>Monthly Payment ($) =</p></td>
  142. ;        <td><input type="text" name="paym" size="10"><input type="text" name="comp"
  143. ;value="Canadian" size="10"></td>
  144. ;      </tr>
  145. ;      <tr>
  146. ;        <td align="right">
  147. ;        
  148. ;        <p>Still Owing at End of Term ($) =</p></td>
  149. ;        <td><input type="text" name="owed" size="10"></td>
  150. ;      </tr>
  151. ;    </table></div></form>
  152.  
  153.  
  154. [`Caption`]
  155. Kind=S
  156. Value=Mortgage Calculator using either the Canadian or U.S. Formula
  157.  
  158.  
  159.